let shouldContinue = true;
async function fetchData() {
    while (shouldContinue) {
        const data = await fetch('https://api.example.com/data');
        console.log(data);
    }
}
fetchData();
// 当需要停止时
shouldContinue = false;
